package com.company.observer.v04;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Child child = new Child();
//        while (!child.isCry()){
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//            System.out.println("observer........");
//        }
        child.wakeUp();
    }
}

class Dad implements Observer {
    public void feed() {
        System.out.println("Dad feeding.............");
    }

    @Override
    public void actionWakeUp() {
        feed();
    }
}

class Mum implements Observer {

    @Override
    public void actionWakeUp() {
        hug();
    }

    public void hug() {
        System.out.println("mum.hug........");
    }
}

class Dog implements Observer {

    @Override
    public void actionWakeUp() {
        Talk();
    }

    public void Talk() {
        System.out.println("........");
    }
}

interface Observer {
    void actionWakeUp();
}


class Child {
    private boolean cry = false;
    List<Observer> list = new ArrayList<>();

    {
        list.add(new Dad());
        list.add(new Mum());
        list.add(new Dog());
    }

    public boolean isCry() {
        return cry;
    }

    public void wakeUp() {
        for (Observer observer :
                list) {
            observer.actionWakeUp();
        }
    }
}